package com.imooc.result;

import com.imooc.ResultEnum.ResultBoyEnum;
import com.sun.org.apache.regexp.internal.RE;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by chenxin on 2017/4/30.
 */
public class ResultUtils {
    public static Result error(Integer code, String message) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        Map map = new HashMap();
        result.setData(map);
        return result;
    }

    public static Result success(Object object) {
        Result result = new Result();
        result.setCode(ResultBoyEnum.SUCCESS.getCode());
        result.setMessage(ResultBoyEnum.SUCCESS.getMessage());
        result.setData(object);
        return result;
    }

    public static Result errorSaveone() {
        Result result = new Result();
        result.setCode(ResultBoyEnum.ERRORSAVEONE.getCode());
        result.setMessage(ResultBoyEnum.ERRORSAVEONE.getMessage());
        Map map = new HashMap();
        result.setData(map);
        return result;
    }
}
